<template>
	<view class="">
		<view class="head">
			<view class="tex">
				<text class="tex-1">问止 · 外治图解</text>
				<text>专业的中医治疗性疗法</text>
			</view>
			<view class="search">
				<image src="../../static/search.png" mode="widthFix"></image>
			</view>
		</view>
		<view class="line"></view>
		<view class="content">
			<scroll-view class="nav" scroll-y>
				<view :class="['item',active === item.id ? 'active' : '']" @click="getlist(item)" v-for="item in list"
					:key="item.id">{{item.user}}</view>
			</scroll-view>
			<scroll-view class="list-rigth" scroll-y>
				<view v-for="item in info" :key="item.id">
					<view class="list-rigth-title">
						<text class="list-rigth-line-1"></text>
						<text class="list-rigth-tex">{{item.illness}}</text>
						<text class="list-rigth-line-2"></text>
					</view>
					<view class="list-rigth-item" v-for="item1 in item.listdata" :key="item1.id"
						@click="gonewuser(active,item.id,item1.id)">{{item1.list}}</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import axios from "../../bower_components/axios/dist/axios.js";
	export default {
		data() {
			return {
				active: 1,
				list: [],
				info: [],
			}
		},
		onLoad() {
			this.getdata()
		},
		methods: {
			getdata() {
				// 用axios 获取数据
				axios.get("/user/list").then((res) => {
					this.list = res.data.data
					this.info = res.data.data[0].title
					this.active = res.data.data[0].id
					console.log(res.data.data);
				});
			},
			//点击展示相应的数据
			getlist(item) {
				this.active = item.id
				this.info = item.title
			},
			// 跳转
			gonewuser(id, cid, listid) {
				uni.navigateTo({
					url: `/pages/info/info?id=${id}&cid=${cid}&listid=${listid}`
				})
			}
		}
	}
</script>

<style lang="scss">
	.head {
		padding: 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;

		.tex {
			display: flex;
			flex-direction: column;

			.tex-1 {
				font-size: 48rpx;
			}
		}

		.search {
			width: 70rpx;
			height: 70rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}
	}

	.line {
		height: 20rpx;
		background-color: #f3f3f3;
	}

	.content {
		display: flex;
		justify-content: space-between;

		.nav {
			width: 340rpx;
			height: 100%;
			background-color: #ebebeb;
			color: #707070;

			.item {
				line-height: 90rpx;
				font-size: 32rpx;
				text-align: center;

				// 激活项的样式
				&.active {
					background-color: #ffffff;
					position: relative;

					// 渲染激活项左侧的红色指示边线
					&::before {
						content: ' ';
						display: block;
						width: 3px;
						height: 30px;
						background-color: #35BF72;
						position: absolute;
						left: 0;
						top: 50%;
						transform: translateY(-50%);
					}
				}
			}
		}

		.list-rigth {
			margin-top: 15rpx;
			text-align: center;
			white-space: nowrap;

			.list-rigth-title {
				display: flex;
				justify-content: center;
				align-items: center;
				color: #35BF72;
				padding: 15rpx 0;

				.list-rigth-line-1 {
					width: 130rpx;
					height: 3rpx;
					display: inline-block;
					background-image: linear-gradient(to right, #fffbfb, #b5b5b5);
				}

				.list-rigth-line-2 {
					width: 130rpx;
					height: 3rpx;
					display: inline-block;
					background-image: linear-gradient(to left, #fffbfb, #b5b5b5);
				}

				.list-rigth-tex {
					margin: 0 10rpx;
				}

			}

			.list-rigth-item {
				padding: 15rpx 0;
				font-size: 30rpx;
			}
		}
	}
</style>
